<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/jquery/jquery.js"></script>
</head>

<body>
    <div class="layui-container">
        <table class="layui-table">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>年龄</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </div>
    <script>
        function sendAjax() {
            $.ajax({
                url: "/jquery/showUser",
                method: "get",
                dataType:"json",
                success: function (data) {
                    console.log(data);
                    let strs = "";
                    data.forEach(item => {
                        strs += `
                        <tr>
                            <td>${item.name}</td>    
                            <td>${item.age}</td>    
                        </tr>

                    `;
                    });


                    $("tbody").html(strs);
                }
            });
        }
        sendAjax();
    </script>
</body>

</html>